def dfs(x: int):
    global st, deli, totalSum, k, n
    if x > n:
        sum1 = 0
        for i in range(1, len(st)):
            if st[i]:
                sum1 += deli[i]
        if sum1 < k:
            totalSum = totalSum if totalSum > sum1 else sum1
        return
    dfs(x + 1)
    st[x] = True
    dfs(x + 1)
    st[x] = False


totalSum = 0
n, k = map(int, input().split())
deli = list(map(int, input().split()))
deli.insert(0, 0)
st = [False for _ in range(len(deli))]
dfs(1)
print(totalSum)
